function ShowModal(ToolID, ResultContainer, Param) {

	var WindowTitle = "Toolbox";
	var WindowName = "PopOutToolBox";

	ModalWindow = null;
	
	switch (ToolID) {
	
		case "AddressBook":
		
			ModalWindow = dhtmlmodal.open(WindowName, "iframe", "GonzalesToolsAddressBook.aspx", WindowTitle, "width=600px,height=450px,center=1,resize=0,scrolling=0");
		
		    ModalWindow.onclose = function () {
		        var CurrentForm = this.contentDoc.forms[0];
		        
		        if(this.contentDoc.getElementById("hiddenValue").value == "") {
		            var EmployeeInternalID = this.contentDoc.getElementById("employee_internalid").value;
		            var EmployeeName = this.contentDoc.getElementById("employee_name").value;
    		        
				    ResultContainer.value = "EmployeeInternalID=" + EmployeeInternalID + "&EmployeeName=" + EmployeeName;
				    AnalyzeResultByParent();
                }

				return true;
		    }		
		
			break;
			
		case "AddressBookOnReviewOnBehalf":
		
			ModalWindow = dhtmlmodal.open(WindowName, "iframe", "GonzalesToolsAddressBook.aspx", WindowTitle, "width=600px,height=450px,center=1,resize=0,scrolling=0");
		
		    ModalWindow.onclose = function () {
		        var CurrentForm = this.contentDoc.forms[0];
		        
		        if(this.contentDoc.getElementById("hiddenValue").value == "") {
		            var EmployeeInternalID = this.contentDoc.getElementById("employee_internalid").value;
		            var EmployeeName = this.contentDoc.getElementById("employee_name").value;
    		        
				    ResultContainer.value = "EmployeeInternalID=" + EmployeeInternalID + "&EmployeeName=" + EmployeeName;
				    AnalyzeResultByParentForReviewOnBehalf();
                }

				return true;
		    }		
		
			break;			
			
		case "AddressBookOnEmployeeID":
		
			ModalWindow = dhtmlmodal.open(WindowName, "iframe", "GonzalesToolsAddressBookOnEmployeeID.aspx", WindowTitle, "width=600px,height=450px,center=1,resize=0,scrolling=0");
		
		    ModalWindow.onclose = function () {
		        var CurrentForm = this.contentDoc.forms[0];
		        
		        if(this.contentDoc.getElementById("hiddenValue").value == "") {
		            var EmployeeInternalID = this.contentDoc.getElementById("employee_internalid").value;
    		        		        				
				    var RowID = ResultContainer.name.substring (0, 36);
    				
				    AnalyzeResultByParentOnEmployeeID(RowID, EmployeeInternalID);
				
				}

				return true;
		    }		
		
			break;		
			
		case "AddressBookOnCostCenter":
		
			ModalWindow = dhtmlmodal.open(WindowName, "iframe", "GonzalesToolsAddressBookOnCostCenter.aspx", WindowTitle, "width=600px,height=450px,center=1,resize=0,scrolling=0");
		
		    ModalWindow.onclose = function () {
		        var CurrentForm = this.contentDoc.forms[0];
		        
		        if(this.contentDoc.getElementById("hiddenValue").value == "") {
		            var CostCenter = this.contentDoc.getElementById("employee_internalid").value;
    		        		        				
				    var RowID = ResultContainer.name.substring (0, 36);
    				
				    AnalyzeResultByParentOnCostCenter(RowID, CostCenter);
				}

				return true;
		    }		
		
			break;					
			
		case "ExpenseDetail":
		
			ModalWindow = dhtmlmodal.open(WindowName, "iframe", "GonzalesToolsAllExpenseType.aspx", WindowTitle, "width=600px,height=450px,center=1,resize=0,scrolling=0");
		
		    ModalWindow.onclose = function () {
		        
                var RowID = ResultContainer.name.substring (0, 36);	
                
                if(this.contentDoc.getElementById("hiddenValue").value == "")
                {
                    ResultContainer.value = this.contentDoc.getElementById("claimtype_gl").value + " - " + this.contentDoc.getElementById("claimtype_name").value;
                    document.getElementById(RowID + "_HiddenFieldGLCode").value = this.contentDoc.getElementById("claimtype_gl").value;
                    document.getElementById(RowID + "_HiddenField_ExpenseDetailID").value = this.contentDoc.getElementById("claimtype_id").value;
                }
				return true;
		    }		
		
			break;			
			
		case "Mileage":
		
			ModalWindow = dhtmlmodal.open(WindowName, "iframe", "GonzalesToolsMileage.aspx?" + Param, WindowTitle, "width=455px,height=350px,center=1,resize=0,scrolling=0");
		
		    ModalWindow.onclose = function () {
		        var CurrentForm = this.contentDoc.forms[0];
		        
		        if(this.contentDoc.getElementById("hiddenClose").value == ""){
		            var Result = this.contentDoc.getElementById("TextBox_From").value.replace(/,/g, "_") + "-" + this.contentDoc.getElementById("TextBox_To").value.replace(/,/g, "_") + "," + this.contentDoc.getElementById("TextBox_Purpose").value.replace(/,/g, "_") + "," + this.contentDoc.getElementById("TextBox_Distance").value;
    		        
				    ResultContainer.value = Result;	
    				
				    var RowID = ResultContainer.name.substring (0, 36);				
				    document.getElementById(RowID + "_TextBoxAmount").value = this.contentDoc.getElementById("TextBox_Total").innerHTML;
				    RowCalculation(RowID);
                 }
				    return true;
		    }	
		    		
			break;
			
		case "FileManager":
		
      ModalWindow = dhtmlmodal.open(WindowName, "iframe", "GonzalesFileManager.aspx?" + Param, WindowTitle, "width=600px,height=450px,center=1,resize=0,scrolling=0");
		
			break;		
			
		case "Entertainment":
		
      ModalWindow = dhtmlmodal.open(WindowName, "iframe", "GonzalesToolsEntertainment.aspx?" + Param, WindowTitle, "width=600px,height=450px,center=1,resize=0,scrolling=0");
     					
		    ModalWindow.onclose = function () {
		        var CurrentForm = this.contentDoc.forms[0];
		        if(this.contentDoc.getElementById("hiddenClose").value == ""){ 
		            var Result = "[ENT]" + this.contentDoc.getElementById("TextBox_Purpose").value.replace(/,/g, "_") + "," + this.contentDoc.getElementById("HiddenField_TotalParticipants").value;
    		        
		              //alert(this.contentDoc.getElementById("TextBox_Purpose").value);
    		          
				    ResultContainer.value = Result;		
    				
                    var RowID = ResultContainer.name.substring (0, 36);				
				    document.getElementById(RowID + "_TextBoxAmount").value = this.contentDoc.getElementById("TextBox_TotalCost").value;
				    RowCalculation(RowID);							
                }
				return true;
		    }	
		    		      
		
			break;	
			
		case "EntertainmentForCust":
		
      ModalWindow = dhtmlmodal.open(WindowName, "iframe", "GonzalesToolsEntertainmentForCust.aspx?" + Param, WindowTitle, "width=600px,height=450px,center=1,resize=0,scrolling=0");
     					
		    ModalWindow.onclose = function () {
		        var CurrentForm = this.contentDoc.forms[0];
		        //var Result = "[ENT]" + this.contentDoc.getElementById("TextBox_Purpose").value.replace(",", "_") + "," + this.contentDoc.getElementById("HiddenField_TotalParticipants").value;
		        //Added by Agnes    
		        if(this.contentDoc.getElementById("hiddenClose").value == ""){      
		            var Result = "[ENT]" + this.contentDoc.getElementById("TextBox_Purpose").value.replace(/,/g, "_") + "," + this.contentDoc.getElementById("HiddenField_TotalParticipants").value;

				    ResultContainer.value = Result;		
    				
                    var RowID = ResultContainer.name.substring (0, 36);				
				    document.getElementById(RowID + "_TextBoxAmount").value = this.contentDoc.getElementById("TextBox_TotalCost").value;
				    RowCalculation(RowID);							
                }
				return true;
		    }	
		    		      
		
			break;	
			
		case "EntertainmentForGift":
		
      ModalWindow = dhtmlmodal.open(WindowName, "iframe", "GonzalesToolsEntertainmentForGift.aspx?" + Param, WindowTitle, "width=600px,height=450px,center=1,resize=0,scrolling=0");
     					
		    ModalWindow.onclose = function () {
		        var CurrentForm = this.contentDoc.forms[0];
		        //var Result = "[ENT]" + this.contentDoc.getElementById("TextBox_Purpose").value.replace(",", "_") + "," + this.contentDoc.getElementById("TextBox_NoOfParticipants").value;
		        //Added By Agnes	
		        if(this.contentDoc.getElementById("hiddenClose").value == ""){         
		            var Result = "[ENT]" + this.contentDoc.getElementById("TextBox_Purpose").value.replace(/,/g, "_") + "," + this.contentDoc.getElementById("TextBox_NoOfParticipants").value;
    		        
				    ResultContainer.value = Result;
    				
                    var RowID = ResultContainer.name.substring (0, 36);				
				    document.getElementById(RowID + "_TextBoxAmount").value = this.contentDoc.getElementById("TextBox_TotalCost").value;
				    RowCalculation(RowID);							
                }
				return true;
		    }	
		    		      
		
			break;							
						
		case "ProjectBrowser":

		    ModalWindow = dhtmlmodal.open(WindowName, "iframe", "GonzalesToolsProject.aspx" + Param, WindowTitle, "width=500px,height=180px,center=1,resize=0,scrolling=0");
		
		    ModalWindow.onclose = function () {
		        var CurrentForm = this.contentDoc.forms[0];
		        if(this.contentDoc.getElementById("hiddenValue").value == ""){
		            var Result = this.contentDoc.getElementById("DropDownList_Project")[this.contentDoc.getElementById("DropDownList_Project").selectedIndex].value;
		        
				    ResultContainer.value = Result;	
				 }
				
				return true;
		    }	
		    		
			break;
			
		case "PublishTransport":
		
			ModalWindow = dhtmlmodal.open(WindowName, "iframe", "GonzalesToolsPublicTransport.aspx?" + Param, WindowTitle, "width=395px,height=300px,center=1,resize=0,scrolling=0");

		    ModalWindow.onclose = function () {
		        var CurrentForm = this.contentDoc.forms[0];
		        //var Result = this.contentDoc.getElementById("TextBox_Type").value.replace(",", "_") + "," + this.contentDoc.getElementById("TextBox_From").value.replace(",", "_") + "-" + this.contentDoc.getElementById("TextBox_To").value.replace(",", "_") + "," + this.contentDoc.getElementById("TextBox_Purpose").value.replace(",", "_") + "," + this.contentDoc.getElementById("TextBox_TotalCost").value;
		        //added by Agnes
		        if(this.contentDoc.getElementById("hiddenClose").value == ""){
		            var Result = this.contentDoc.getElementById("TextBox_Type").value.replace(/,/g, "_") + "," + this.contentDoc.getElementById("TextBox_From").value.replace(/,/g, "_") + "-" + this.contentDoc.getElementById("TextBox_To").value.replace(/,/g, "_") + "," + this.contentDoc.getElementById("TextBox_Purpose").value.replace(/,/g, "_") + "," + this.contentDoc.getElementById("TextBox_TotalCost").value;
    		        
				    ResultContainer.value = Result;		
                    var RowID = ResultContainer.name.substring (0, 36);				
				    document.getElementById(RowID + "_TextBoxAmount").value = this.contentDoc.getElementById("TextBox_TotalCost").value;
				    RowCalculation(RowID);						
                }
				return true;
		    }	
		    		
			break;					
			
		case "Taxi":
		
			ModalWindow = dhtmlmodal.open(WindowName, "iframe", "GonzalesToolsTaxi.aspx?" + Param, WindowTitle, "width=395px,height=300px,center=1,resize=0,scrolling=0");
		
		    ModalWindow.onclose = function () {
		    		    
		        var CurrentForm = this.contentDoc.forms[0];
		        //var Result = this.contentDoc.getElementById("TextBox_Type").value.replace(",", "_") + "," + this.contentDoc.getElementById("TextBox_From").value.replace(",", "_") + "-" + this.contentDoc.getElementById("TextBox_To").value.replace(",", "_") + "," + this.contentDoc.getElementById("TextBox_Purpose").value.replace(",", "_") + "," + this.contentDoc.getElementById("TextBox_TotalCost").value;
		        //added by Agnes
		        if(this.contentDoc.getElementById("hiddenClose").value == ""){
		            var Result = this.contentDoc.getElementById("TextBox_Type").value.replace(/,/g, "_") + "," + this.contentDoc.getElementById("TextBox_From").value.replace(/,/g, "_") + "-" + this.contentDoc.getElementById("TextBox_To").value.replace(/,/g, "_") + "," + this.contentDoc.getElementById("TextBox_Purpose").value.replace(/,/g, "_") + "," + this.contentDoc.getElementById("TextBox_TotalCost").value;
    		        
				    ResultContainer.value = Result;		
    				
                    var RowID = ResultContainer.name.substring (0, 36);				                
				    document.getElementById(RowID + "_TextBoxAmount").value = this.contentDoc.getElementById("TextBox_TotalCost").value;
				    RowCalculation(RowID);						
                }

				return true;
		    }			    	   		  	    		   			    
		    		
			break;			
		//update by mei chze on 28/08/2012
		case "AddressBookCurrentApprover":
		
			ModalWindow = dhtmlmodal.open(WindowName, "iframe", "GonzalesToolsAddressBook.aspx", WindowTitle, "width=600px,height=450px,center=1,resize=0,scrolling=0");
		
		    ModalWindow.onclose = function () {
		        var CurrentForm = this.contentDoc.forms[0];
		        
		        if(this.contentDoc.getElementById("hiddenValue").value == "") {
		            var EmployeeInternalID = this.contentDoc.getElementById("employee_internalid").value;
		            var EmployeeName = this.contentDoc.getElementById("employee_name").value;
    		        
				    ResultContainer.value = "EmployeeInternalID=" + EmployeeInternalID + "&EmployeeName=" + EmployeeName;
				    AnalyzeResultByParentCurApp();
                }

				return true;
		    }		
		
			break;
	}


}

function AnalyzeModalResult(ResultContainer) {
	var ResultArray = ResultContainer.value.split("&");
	var FinalArray = new Array();
	for (var x = 0; x < ResultArray.length; x++) {
		Tmp = ResultArray[x].split("=");
		FinalArray[Tmp[0]] = Tmp[1];					
	}
	return FinalArray;
	
}